﻿using System;
using System.Diagnostics;

namespace MangosRestarter
{
    /// <summary>
    /// MySQL进程检查器
    /// </summary>
    internal static class MySqlChecker
    {
        /// <summary>
        /// 检查MySQL进程是否运行
        /// </summary>
        internal static bool IsRunning()
        {
            try
            {
                return Process.GetProcessesByName("mysqld").Length > 0 ||
                       Process.GetProcessesByName("mysqld-nt").Length > 0;
            }
            catch (Exception ex)
            {
                Logger.Write($"[MySqlChecker] 检测进程时发生异常: {ex.Message}");
                return false;
            }
        }
    }
}